export function oneOption(text, data, startValue, endValue) {
    let num = 0;
    if (text == "wind商品") {
        num = 10;
    } else if (text == "3个月定存利率") {
        num = 6;
    } else {
        num = 500;
    };
    let option = {
        title: {
            text: text,
            x: 'center',
            top: "12%"
        },
        tooltip: {
            trigger: 'axis',
            formatter: '{b}<br />{a0}:\n{c0}',
        },
        xAxis: {
            type: 'category',
            data: data.dateMap
        },
        yAxis: {
            type: 'value',
            //max: "dataMax",
            min: "dataMin",
            splitNumber: 3,
            boundaryGap: [0.1, 0.1],
            axisLabel: {
                formatter: function(v) {
                    return parseInt(v) //表示整数。其他数值类型以此类推
                }
            },
            splitLine: { //网格线
                lineStyle: {
                    type: 'dashed' //设置网格线类型 dotted：虚线   solid:实线
                },
                show: true //隐藏或显示
            },


        },
        dataZoom: [{
                type: 'slider',
                showDetail: false,
                xAxisIndex: [0],
                // startValue: startValue,
                // endValue: endValue,
                throttle: 50,
                minValueSpan: num,
                //maxValueSpan: 1500,
                //start: 100,
                //end: 20,
                handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                handleSize: '50%',
                //zoomLock:false,

            },
            //下面这个属性是里面拖到
            {
                type: 'inside',
                //zoomOnMouseWheel:false,
                moveOnMouseMove: false,
            },
        ],
        series: {
            name: '当天值',
            type: 'line',
            data: data.blueMap,
            symbol: 'none', //取消折点圆圈
            itemStyle: {
                normal: {
                    color: '#0e9cff', //改变折线点的颜色
                    lineStyle: {
                        color: '#0e9cff' //改变折线颜色
                    }
                }
            },

        }

    }
    return option;
};
export function twoOption(text, data, name1, name2, startValue, endValue, yname, type, id) {
    let yAxis;
    let series;
    let dataZoom;
    if (type === 'FOF') {
        yAxis = {
            name: yname,
            type: 'value',
            min: "dataMin",
            splitNumber: 3,
            boundaryGap: [0.1, 0.1],
            axisLabel: {
                formatter: function(v) {
                    return parseInt(v) //表示整数。其他数值类型以此类推
                }
            },
            // axisLabel:{formatter:'{value} %'},
            splitLine: { //网格线
                lineStyle: {
                    type: 'dashed' //设置网格线类型 dotted：虚线   solid:实线
                },
                show: true //隐藏或显示
            },
            axisLabel: {
                formatter: function(value, index) {  return Number(value).toFixed(2) + '%';                      }
            },

        };
        if (id === '1') {
            series = [{
                    name: name1,
                    type: 'line',
                    // data: data.blueMap,
                    data: data.redMap,
                    symbol: 'none', //取消折点圆圈
                    itemStyle: {
                        normal: {
                            color: '#0e9cff', //改变折线点的颜色
                            lineStyle: {
                                color: '#0e9cff' //改变折线颜色
                            }
                        }
                    },
                },
                {
                    name: name2,
                    type: 'line',
                    // data: data.redMap,
                    data: data.blueMap,
                    symbol: 'none',
                    itemStyle: {
                        normal: {
                            color: '#f38143',
                            lineStyle: {
                                color: '#f38143'
                            }
                        }
                    },
                }
            ];
        } else {
            series = [{
                    name: name1,
                    type: 'line',
                    data: data.blueMap,
                    // data: data.redMap,
                    symbol: 'none', //取消折点圆圈
                    itemStyle: {
                        normal: {
                            color: '#0e9cff', //改变折线点的颜色
                            lineStyle: {
                                color: '#0e9cff' //改变折线颜色
                            }
                        }
                    },
                },
                {
                    name: name2,
                    type: 'line',
                    data: data.redMap,
                    // data: data.blueMap,
                    symbol: 'none',
                    itemStyle: {
                        normal: {
                            color: '#f38143',
                            lineStyle: {
                                color: '#f38143'
                            }
                        }
                    },
                }
            ];
        }

        dataZoom = [{
                type: 'slider',
                throttle: 20,
                showDetail: false,
                minValueSpan: 5,
                handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                handleSize: '50%',
                //zoomLock:false,
            },
            //下面这个属性是里面拖到
            {
                type: 'inside',
                //zoomOnMouseWheel:false,
                moveOnMouseMove: false,
            },
        ]
    } else {
        yAxis = {
                name: yname,
                type: 'value',
                min: "dataMin",
                splitNumber: 3,
                boundaryGap: [0.1, 0.1],
                axisLabel: {
                    formatter: function(v) {
                        return parseInt(v) //表示整数。其他数值类型以此类推
                    }
                },
                // axisLabel:{formatter:'{value} %'},
                splitLine: { //网格线
                    lineStyle: {
                        type: 'dashed' //设置网格线类型 dotted：虚线   solid:实线
                    },
                    show: true //隐藏或显示
                },
            },
            series = [{
                    name: name1,
                    type: 'line',
                    data: data.blueMap,
                    // symbol: 'none',  //取消折点圆圈
                    itemStyle: {
                        normal: {
                            color: '#0e9cff', //改变折线点的颜色
                            lineStyle: {
                                color: '#0e9cff' //改变折线颜色
                            }
                        }
                    },
                },
                {
                    name: name2,
                    type: 'line',
                    data: data.redMap,
                    // symbol: 'none',
                    itemStyle: {
                        normal: {
                            color: '#f38143',
                            lineStyle: {
                                color: '#f38143'
                            }
                        }
                    },
                }
            ];
        dataZoom = [{
                type: 'slider',
                showDetail: false,
                // startValue: startValue,
                // endValue: endValue,
                throttle: 20,
                minValueSpan: 5,
                handleIcon: 'M10.7,11.9v-1.3H9.3v1.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4v1.3h1.3v-1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7V23h6.6V24.4z M13.3,19.6H6.7v-1.4h6.6V19.6z',
                handleSize: '50%',
                //zoomLock:false,

            },
            //下面这个属性是里面拖到
            {
                type: 'inside',
                //zoomOnMouseWheel:false,
                moveOnMouseMove: false,
            },
        ]
    };
    // let  option={
    //      title: {
    //         text: text,
    //       },
    //       tooltip: {
    //         trigger: 'axis',
    //         formatter:'{b}<br />{a0}:\n{c0}%<br />{a1}:\n{c1}%',
    //       },
    //       legend: {
    //         data:[name1,name2]
    //       },
    //       xAxis:  {
    //         type: 'category',
    //         data:data.dateMap
    //       },
    //       yAxis,
    //       dataZoom,
    //       series,
    //        }
    let option;
    if (type === 'FOF') {
        option = {
            title: {
                text: text,
            },
            tooltip: {
                trigger: 'axis',
                formatter: '{b}<br />{a0}:\n{c0}%<br />{a1}:\n{c1}%',


            },
            legend: {
                data: [name1, name2]
            },
            xAxis: {
                type: 'category',
                data: data.dateMap
            },
            yAxis,
            dataZoom,
            series,
        }
    } else {
        option = {
            title: {
                text: text,
            },
            tooltip: {
                trigger: 'axis',
                // formatter: '{b}<br />{a0}:\n{c0}%1<br />{a1}:\n{c1}%',
                formatter: function(v1) {

                    let yg = v1[0].value
                    if (yg) {
                        return v1[0].axisValue + '<br/>' + text + ':' + yg + "%"
                    } else {
                        return v1[1].axisValue + '<br/>' + text + ':' + v1[1].value + "%"
                    }
                }

            },
            legend: {
                data: [name1, name2]
            },
            xAxis: {
                type: 'category',
                data: data.dateMap
            },
            yAxis,
            dataZoom,
            series,
        }
    }
    return option;
};